home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 436 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Array Parameters
  5. Date: 04 Jan 1996 20:06:49 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan4150649@g7240065.bridge.bst.bls.com>
  8. References: <wayne.820650643@hawk> <4ce349$4j9@hacgate2.hac.com>
  9.     <820701694snz@genesis.demon.co.uk> <4cg104$qmp@nervous.pdb.sni.de>
  10.     <4cgmuc$k9k@hacgate2.hac.com>
  11. NNTP-Posting-Host: bstfirewall.bst.bls.com
  12. In-reply-to: collins@thor.tu.hac.com's message of 4 Jan 1996 14:07:08 GMT
  13.  
  14. In article <4cgmuc$k9k@hacgate2.hac.com> collins@thor.tu.hac.com (Ron Collins) writes:
  15.  
  16. : Josef Moellers (mollers.pad@sni.de) wrote:
  17. : : In <820701694snz@genesis.demon.co.uk> Lawrence Kirby <fred@genesis.demon.co.uk> writes:
  18.  
  19. :: [ ... ]
  20. ::>                             It is impossible
  21. ::> to specify an array as a function parameter since, as in the example above,
  22.  
  23. :: Well, if you MUST pass an array by value and not by reference, wrap it
  24. :: into a structure:
  25.  
  26. :: struct foo {
  27. ::     int array[100];
  28. :: };
  29. :: ...
  30.  
  31. : I don't get it ... what does this buy me ("me" == any competant C programmer)?
  32. : I'm still going to get a pointer-to-something, whether it's a pointer-to-
  33. : structure, pointer-to-array, or pointer-to-first-element.  I still need to
  34. : know which one is used so I can access the array elements properly.  (Although,
  35. : there is seldom any difference between passing a pointer to an array, and
  36. : a pointer to the first element of that array).
  37.  
  38. In 'C' you can pass structures by value, this includes all the contents of
  39. that structure. So it gets you ("you" == any competent C programmer ;') what you
  40. require, if you require the array by value - with the cost of accessing the
  41. array through a structure. Personally I would refrain from such practices
  42. because I feel they are (the big technical word of the day) icky!
  43.  
  44. : BTW, passing a pointer to an object is _not_ the same as pass by reference.
  45. : C does not support pass-by-reference at all.
  46.  
  47. True, very true - I think what he wrote was a case of quick fingers and slow
  48. thoughts, and not true misunderstanding. ;')
  49.  
  50. Regards
  51.  
  52.     -A.
  53. -- 
  54. | A.Champion                |
  55.